home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / Pool.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.0 KB  |  103 lines

  1. #ifndef _POOL_H_
  2. #define _POOL_H_
  3. /*
  4.  *   $RCSfile: Pool.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:07 $      
  7.  */ 
  8.  
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40. #ifndef __cplusplus
  41.     This file MUST be compiled with C++ !
  42. #endif
  43.  
  44.  
  45. #include "sysdefs.h"
  46. #include "checking.h"
  47. #include "ess.h"
  48. #include "list.h"
  49. #include "trace.h"
  50. #include "error.h"
  51. #include "ForEach.h"
  52.  
  53. #define POOL_NOMORE_NULL       0x0     /* quietly return null if we run out */
  54. #define POOL_NOMORE_GETMORE   0x1     /* get more if we run out  */
  55. #define POOL_NOMORE_ISERROR  0x2     /* nonfatal error if we run out  */
  56. #define POOL_NOMORE_ISFATAL  0x4     /* fatal error if we run out  */
  57.                             /* none of these--> return null if run out */
  58.  
  59. template <class CONTENTS>
  60. class Pool {
  61.  
  62. private:
  63.     LIST        freeList;        /* list of available elements */
  64.     LIST        mallocedList;        /* list of malloc-ed areas */
  65.     int            nmallocs;
  66.     int            totalQty;        /* in elements */
  67.     int            lastMallocedQty;        /* # elements last  malloced */
  68.     int            elementSize;    /* in bytes */
  69.     int            currentUsed;
  70.     int            maxUsed;        /* high water mark */
  71.     FLAGS        flags;
  72.     char        name[32];
  73.     int            unique; /* id of resource */
  74.     int            spaceRequirement;    /* in # bytes */
  75.  
  76. private: 
  77.     void listMake( LIST *list, LIST *mallocList, int elementQty); 
  78.  
  79.     /* 
  80.      * The CONTENTS class must have these member functions:
  81.      * void Init();
  82.      * void ReInit();
  83.      * LISTELEMENT *listlocation(int);
  84.      */
  85. public:
  86.     Pool( char *, int, int, FLAGS);
  87.     ~Pool();
  88.     void            Stats( FILE * );
  89.     CONTENTS        *Get();
  90.     void            Put( CONTENTS *);
  91.     void            Move( CONTENTS *);
  92. #ifdef __GNUC__
  93.     void    ForEach(  int, ... ) ;
  94. #else
  95.     void    ForEach(  int, FOREACHFUNC, ... ) ;
  96. #endif
  97. };
  98.  
  99. #ifdef  __GNUC__
  100. #include "Pool.c"
  101. #endif  __GNUC__
  102. #endif /* _POOL_H_ */
  103.